//引入公共文件
import '@utils/init.js';

import ajax from '@utils/ajax.js'

$('#loginBtn').click(async() => {
    const username = $('#username').val();
    const userpass = $('#password').val();
    const res = await ajax({
        url: '/users/login',
        type: 'POST',
        data: {
            username,
            userpass
        },
    })
    if (res.code) {
        alert('登录成功');
        localStorage.token = res.token;
        location.href = '../index.html'

    } else {
        alert('登录失败')
    }
})